<?php
/**
 * Author: Adam
 * Create at 2018/9/29.
 */

namespace App\Utils;

class Response
{
    const RESPONSE_ERROR_CODE = 4000;//请求失败
    const RESPONSE_SUCCESS_CODE = 2000;//请求成功
    const RESPONSE_NO_LOGIN = 3000;//未登录


    public static function successJson($msg = '', $data = [], $url = '')
    {
        return static::jsonMsg(static::RESPONSE_SUCCESS_CODE, $msg, $data, $url);
    }

    public static function errorJson($msg = '', $data = [], $url = '')
    {
        return static::jsonMsg(static::RESPONSE_ERROR_CODE, $msg, $data, $url);
    }

    public static function jsonMsg($status, $msg = '', $data = [], $url = '')
    {
        return response()->json([
            'status' => $status,
            'msg' => $msg,
            'data' => $data,
            'url' => $url
        ]);
    }
}
